document.querySelector(".fanhui").onclick = function () {
    location.href = "./index.html"
}

// 搜索列表
let Oscech = document.getElementById('scech');
function searchInput() {
    // 添加对空格和回车键的事件监听
    Oscech.addEventListener('keydown', function (event) {
        // 检查是否按下空格或者回车键（请注意，键盘码可能因浏览器而异）
        if (event.key === 'Enter') {
            search(Oscech.value)
        }
    });
}


function search(Oscech) {
    ajaxUsePromise02({
        url: `http://121.89.205.189:3000/api/pro/search?keyword=${Oscech}`,
        method: "get",
    }).then(res => {
        if (res.code == '200') {

            let data = res.data
            console.log(data);
            let oUl = document.querySelector('.seach-box');
            let oLis = oUl.children

            for (let i = 0; i < data.length; i++) {

                oUl.innerHTML += `<li class='seach-tit'></li>`
            }
            for (let i = 0; i < oLis.length; i++) {
                oLis[i].innerHTML = data[i].proname;
                oLis[i].onclick = function () {
                    location.href = `./list2.html?proid=${data[i].proid}`
                    console.log(data[i].proid);
                }
            }
        }
    })
}



window.onload = function () {
    searchInput()
}